import React, { useState, useEffect } from 'react'

function App () {
  
  const [nameState, setNameState] = useState('球球')
  const [ageState, setAgeState] = useState(1)

  useEffect(() => {
    console.log("获取列表")
  })

  useEffect(() => {
    console.log("判断是否登录")
  })

  useEffect( () => {
    console.log("挂载更新完成")
    return () => {
      console.log("卸载完成")
    }
  }, [nameState])

  return (
    <div>
      数据{nameState}
      年龄{ageState}
      <button onClick={ () => { setNameState("tutu") } }>修改名称</button>
      <button onClick={ () => { setAgeState( (pre) => pre + 1 ) } }>年龄+1</button>
    </div>
  )
}

export default App